home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fndwnd / findwnd.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  4.1 KB  |  121 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Find Window"
  5.    ClientHeight    =   1365
  6.    ClientLeft      =   1125
  7.    ClientTop       =   2250
  8.    ClientWidth     =   4335
  9.    Height          =   1770
  10.    Icon            =   FINDWND.FRX:0000
  11.    Left            =   1065
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   1365
  16.    ScaleWidth      =   4335
  17.    Top             =   1905
  18.    Width           =   4455
  19.    Begin TextBox Text2 
  20.       Height          =   315
  21.       Left            =   1320
  22.       TabIndex        =   1
  23.       Text            =   "Microsoft Excel"
  24.       Top             =   960
  25.       Width           =   2055
  26.    End
  27.    Begin CommandButton btnQuit 
  28.       Caption         =   "&Quit"
  29.       Height          =   615
  30.       Left            =   3540
  31.       TabIndex        =   3
  32.       Top             =   660
  33.       Width           =   735
  34.    End
  35.    Begin TextBox Text1 
  36.       Height          =   315
  37.       Left            =   1320
  38.       TabIndex        =   0
  39.       Text            =   "XLMAIN"
  40.       Top             =   660
  41.       Width           =   2055
  42.    End
  43.    Begin CommandButton btnFind 
  44.       Caption         =   "&Find"
  45.       Height          =   615
  46.       Left            =   3540
  47.       TabIndex        =   2
  48.       Top             =   60
  49.       Width           =   735
  50.    End
  51.    Begin PictureBox Picture1 
  52.       BorderStyle     =   0  'None
  53.       Height          =   615
  54.       Left            =   1500
  55.       ScaleHeight     =   615
  56.       ScaleWidth      =   1815
  57.       TabIndex        =   4
  58.       TabStop         =   0   'False
  59.       Top             =   0
  60.       Width           =   1815
  61.    End
  62. '**********************************************************'
  63. '*                                                        *'
  64. '*                      Find Window                       *'
  65. '*                                                        *'
  66. '*   Find Window allows you to type a Caption and/or      *'
  67. '*   ClassName into the textboxes on the form and see     *'
  68. '*   if a Window exists that matches those criteria.  I   *'
  69. '*   use it to check on the format of captions used in    *'
  70. '*   applications to make sure I haven't mistaken a set   *'
  71. '*   of parenthesis for a set of square brackets, etc...  *'
  72. '*   It's also useful when you use SPY to find Class      *'
  73. '*   Names and you want to make sure it's not lying to    *'
  74. '*   you<g>.  Do with it as you will.                                            *'
  75. '*                                                        *'
  76. '*   Let me know if you find it useful, or not.           *'
  77. '*                                                        *'
  78. '*   Gregg Irwin CIS:ID  72450,676                        *'
  79. '*                                                        *'
  80. '**********************************************************'
  81. DefInt A-Z
  82. Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any, ByVal lpCaption As Any)
  83. Const KEY_ENTER = 13
  84. Const NULL = 0&
  85. Sub btnFind_Click ()
  86.     lpClassName$ = Text1.Text
  87.     lpCaption$ = Text2.Text
  88.     Picture1.Cls
  89.     Picture1.Print " Handle = "; FindWindow(lpClassName$, NULL)
  90.     Picture1.Print " Handle = "; FindWindow(NULL, lpCaption$)
  91.     Picture1.Print " Handle = "; FindWindow(lpClassName$, lpCaption$)
  92. End Sub
  93. Sub btnQuit_Click ()
  94.     End
  95. End Sub
  96. Sub Form_Paint ()
  97.      CurrentX = 120: CurrentY = 720
  98.     Print "ClassName :"
  99.      CurrentX = 420: CurrentY = 1020
  100.     Print "Caption :"
  101.      CurrentX = 0: CurrentY = 0
  102.     Print " ClassName Only"
  103.     Print " Caption Only"
  104.     Print " Class & Caption"
  105. End Sub
  106. Sub Form_Unload (Cancel As Integer)
  107.     End
  108. End Sub
  109. Sub Text1_KeyPress (KeyAscii As Integer)
  110.     If KeyAscii = KEY_ENTER Then    'If Enter is hit
  111.         KeyAscii = 0                'Supress beep
  112.         SendKeys "{TAB}"            'Go to next field
  113.     End If
  114. End Sub
  115. Sub Text2_KeyPress (KeyAscii As Integer)
  116.     If KeyAscii = KEY_ENTER Then
  117.         KeyAscii = 0
  118.         SendKeys "{TAB}"
  119.     End If
  120. End Sub
  121.